<script setup>
import { reactive, ref, onMounted, computed } from 'vue';
import { Edit, Delete } from '@element-plus/icons-vue';
import channelEdit from './compnents/ChannelEdit.vue';
import {
  articleList,
  addArticle,
  articleDetails,
  deleteArticle
} from '@/api/article';
const list = ref([
  {
    id: 1070,
    cate_name: '科技',
    cate_alias: 'keji'
  },
  {
    id: 1071,
    cate_name: '历史',
    cate_alias: 'lishi'
  }
]);
const getList = async () => {
  loading.value = true;
  const res = await articleList();
  // list.value = res.data.data;
  loading.value = false;
  console.log(list.value, '123');
};
onMounted(() => {
  getList();
});
const onDetele = async (row) => {
  await deleteArticle(row.id);
};
// const onEdit=async (row)=>{
//   await
// }
const loading = ref(false);
const title = ref('');
const dialog = ref(null);
const addItem = () => {
  title.value = '添加分类';
  dialog.value.open({});
};
const EditItem = (row) => {
  title.value = '编辑';
  dialog.value.open(row);
};
const onSuccess = () => {
  getList();
};
</script>

<template>
  <page-Container title="文章分类">
    <template #extra>
      <el-button @click="addItem">添加分类</el-button>
    </template>
    <el-table v-loading="loading" :data="list" style="width: 100%">
      <el-table-column
        type="index"
        fixed
        prop="id"
        width="120px"
        label="序号"
      />
      <el-table-column prop="cate_name" label="分类名称" />
      <el-table-column prop="cate_alias" label="分类别名" />
      <el-table-column fixed="right" label="操作" min-width="120">
        <template #default="{ row }">
          <el-button
            type="danger"
            circle
            plain
            size="small"
            @click="onDetele(row)"
            :icon="Delete"
          >
          </el-button>
          <el-button
            :icon="Edit"
            type="primary"
            plain
            circle
            @click="EditItem(row)"
            size="small"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <channelEdit ref="dialog" :title="title" @success="onSuccess"></channelEdit>
  </page-Container>
</template>

<style lang="scss" scoped></style>
